package com.cskaoyan.order.converter;

import com.cskaoyan.order.bean.bo.InitOrderBo;
import com.cskaoyan.order.biz.context.CreateOrderContext;
import com.cskaoyan.order.dal.entitys.Order;
import com.cskaoyan.order.dal.entitys.OrderItem;
import com.cskaoyan.order.dal.entitys.OrderShipping;
import com.cskaoyan.order.dto.*;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.Date;
import java.util.List;

@Mapper(componentModel = "spring")
public interface OrderConverter {

    @Mappings({
            @Mapping(source = "order.payment", target = "orderTotal"),
            @Mapping(source = "order.status", target = "orderStatus"),
            @Mapping(source = "orderShipping.receiverPhone", target = "tel"),
            @Mapping(source = "orderShipping.receiverAddress", target = "streetName"),
            @Mapping(source = "order.buyerNick", target = "userName"),
    })
    OrderDetailResponse order2res(Order order, OrderShipping orderShipping);

    OrderDetailInfo order2detail(Order order);

    @Mappings({})
    OrderItemDto item2dto(OrderItem item);

    @Mappings({})
    OrderShippingDto shipping2dto(OrderShipping shipping);

    List<OrderItemDto> item2dto(List<OrderItem> items);

    @Mappings({})
    OrderDto order2dto(Order order);

    Order orderContextToOrder(CreateOrderContext orderContext, InitOrderBo initOrderBo);

    List<OrderDetailInfo> orderList2detailList(List<Order> order);

}
